home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 2.00 Begin Form Form1 Caption = "Test Temp functions" ClientHeight = 2925 ClientLeft = 1095 ClientTop = 1485 ClientWidth = 5085 Height = 3330 Left = 1035 LinkMode = 1 'Source LinkTopic = "Form1" ScaleHeight = 2925 ScaleWidth = 5085 Top = 1140 Width = 5205 Begin TextBox Text3 Height = 495 Left = 1680 TabIndex = 5 Text = "Text3" Top = 1920 Width = 3015 End Begin CommandButton Command3 Caption = "Environ$" Height = 495 Left = 240 TabIndex = 4 Top = 1920 Width = 1215 End Begin TextBox Text2 Height = 495 Left = 1680 TabIndex = 3 Text = "Text2" Top = 1200 Width = 3015 End Begin CommandButton Command2 Caption = "Temp File" Height = 495 Left = 240 TabIndex = 1 Top = 1200 Width = 1215 End Begin TextBox Text1 Height = 495 Left = 1680 TabIndex = 2 Text = "Text1" Top = 480 Width = 3015 End Begin CommandButton Command1 Caption = "Temp Drive" Height = 495 Left = 240 TabIndex = 0 Top = 480 Width = 1215 End ' GetTempFileName() Flags Const TF_FORCEDRIVE = &H80 Declare Function GetTempDrive Lib "Kernel" (ByVal cDriveLetter As Integer) As Integer Declare Function GetTempFileName Lib "Kernel" (ByVal cDriveLetter As Integer, ByVal lpPrefixString As String, ByVal wUnique As Integer, ByVal lpTempFileName As String) As Integer Sub Command1_Click () X% = 0 TempDrive% = GetTempDrive%(X%) Text1.Text = Chr$(TempDrive% Mod 256) + Chr$(TempDrive% \ 256) End Sub Sub Command2_Click () DriveLetter% = Asc("C") 'Or TF_FORCEDRIVE PrefixString$ = "BAG" Unique% = 0 'if 0 uses time TempFileName$ = Space$(144) UniqueNbr% = GetTempFileName(DriveLetter%, PrefixString$, Unique%, TempFileName$) Text2.Text = RTrim$(TempFileName$) End Sub Sub Command3_Click () E$ = Environ$("TEMP") If Right$(E$, 1) <> "\" Then E$ = E$ + "\" TestFileName$ = "TEST0001.TMP" Ctr% = 1 Debug.Print TestFileName$ Loop1: If Len(Dir$(E$ + TestFileName$)) <> 0 Then Text3.Text = "File: " + TestFileName$ + " exists" Debug.Print E$ + TestFileName$ Ctr% = Ctr% + 1 Mid$(TestFileName$, 5, 4) = Format$(Ctr%, "0000") GoTo Loop1 Else Debug.Print E$ + TestFileName$ Text3.Text = "File: " + TestFileName$ + " doesn't exist" Open E$ + TestFileName$ For Output As #1 Close 1 End If End Sub Sub Form_Click () End End Sub